<?php
/**
 * Library Of Shared Code (LOSC)
 *
 * LICENSE
 *
 * This source file is subject to the New BSD License that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @category   LOSC Framework
 * @package    Record
 * @copyright  Copyright (c) 2008 Robin Skoglund (http://robinsk.net/)
 * @license    http://creativecommons.org/licenses/BSD/  New BSD License
 */

/**
 * Exception thrown when a {@link Losc_Record_AbstractRecord} is invalid
 *
 * @category   LOSC Framework
 * @package    Record
 * @copyright  Copyright (c) 2008 Robin Skoglund (http://robinsk.net/)
 * @license    http://creativecommons.org/licenses/BSD/  New BSD License
 */
class Losc_Record_ValidationException extends Losc_Exception
{
    /**
     * Instance of the invalid record
     *
     * @var Losc_Record_AbstractRecord
     */
    protected $_record;
    
    /**
     * Creates validation exception
     *
     * @param Losc_Record_AbstractRecord $record
     */
    public function __construct(Losc_Record_AbstractRecord $record)
    {
        parent::__construct('The object contains invalid data.');
        $this->_record = $record;
    }
    
    /**
     * Returns validator messages
     *
     * @return array
     */
    public function getMessages()
    {
        return $this->_record->getValidatorMessages();
    }
}
